﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Shopping.Common;
using System.IO;
using System.Text;

public partial class Manage_ErrList : BaseManagePage
{
    protected string QueryDate;
    protected StringBuilder sb = new StringBuilder();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            QueryDate = Utility.G("QueryDate");
            if (string.IsNullOrEmpty(QueryDate))
                QueryDate = DateTime.Now.ToString("yyyy-MM-dd");


            string url = Server.MapPath("~/ErrorLog/" + DateTime.Parse(QueryDate).ToString("yyyyMM") + "/errlog_" + DateTime.Parse(QueryDate).ToString("yyyyMMdd") + ".txt");
            if (File.Exists(url))
            {
                FileInfo _file = new FileInfo(url);
                FileStream fs = new FileStream(url, FileMode.Open, FileAccess.Read);
                StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default);
                sr.BaseStream.Seek(0, SeekOrigin.Begin);
                string str = sr.ReadLine();        //如果文件有内容 
                while (str != null)
                {
                    sb.AppendLine(str + "<br/>");
                    str = sr.ReadLine();
                }
                sr.Close();
                fs.Close();
            }
            else
            {
                sb.AppendLine("没有错误日志记录。");
            }



        }
    }
}